/**
 * Created by dell on 2017/6/26.
 */
(function(config){var ba=navigator.userAgent.toLowerCase(),e=window,da=document,fa=da.documentElement;function T(a){return-1!==ba.indexOf(a)}var ga=/([a-z0-9]*\d+[a-z0-9]*)/;
    function ha(){var a=ia;if(!a)return null;var a=a.toLowerCase(),b=null;if(b=a.match(/angle \((.*)\)/))a=b[1],a=a.replace(/\s*direct3d.*$/,"");a=a.replace(/\s*\([^\)]*wddm[^\)]*\)/,"");if(0<=a.indexOf("intel")){b=["Intel"];0<=a.indexOf("mobile")&&b.push("Mobile");(0<=a.indexOf("gma")||0<=a.indexOf("graphics media accelerator"))&&b.push("GMA");if(0<=a.indexOf("haswell"))b.push("Haswell");else if(0<=a.indexOf("ivy"))b.push("HD 4000");else if(0<=a.indexOf("sandy"))b.push("HD 3000");else if(0<=a.indexOf("ironlake"))b.push("HD");
    else{0<=a.indexOf("hd")&&b.push("HD");var c=a.match(ga);c&&b.push(c[1].toUpperCase())}return b=b.join(" ")}return 0<=a.indexOf("nvidia")||0<=a.indexOf("quadro")||0<=a.indexOf("geforce")||0<=a.indexOf("nvs")?(b=["nVidia"],0<=a.indexOf("geforce")&&b.push("geForce"),0<=a.indexOf("quadro")&&b.push("Quadro"),0<=a.indexOf("nvs")&&b.push("NVS"),a.match(/\bion\b/)&&b.push("ION"),a.match(/gtx\b/)?b.push("GTX"):a.match(/gts\b/)?b.push("GTS"):a.match(/gt\b/)?b.push("GT"):a.match(/gs\b/)?b.push("GS"):a.match(/ge\b/)?
        b.push("GE"):a.match(/fx\b/)&&b.push("FX"),(c=a.match(ga))&&b.push(c[1].toUpperCase().replace("GS","")),0<=a.indexOf("titan")?b.push("TITAN"):0<=a.indexOf("ti")&&b.push("Ti"),b=b.join(" ")):0<=a.indexOf("amd")||0<=a.indexOf("ati")||0<=a.indexOf("radeon")||0<=a.indexOf("firegl")||0<=a.indexOf("firepro")?(b=["AMD"],0<=a.indexOf("mobil")&&b.push("Mobility"),c=a.indexOf("radeon"),0<=c&&b.push("Radeon"),0<=a.indexOf("firepro")?b.push("FirePro"):0<=a.indexOf("firegl")&&b.push("FireGL"),0<=a.indexOf("hd")&&
    b.push("HD"),0<=c&&(a=a.substring(c)),(c=a.match(ga))&&b.push(c[1].toUpperCase().replace("HD","")),b=b.join(" ")):a.substring(0,100)}
    var ja="microsoft basic render driver;vmware svga 3d;Intel 965GM;Intel B43;Intel G41;Intel G45;Intel G965;Intel GMA 3600;Intel Mobile 4;Intel Mobile 45;Intel Mobile 965".split(";"),ka="ActiveXObject"in e,la="devicePixelRatio"in e&&1<e.devicePixelRatio||ka&&"matchMedia"in e&&e.matchMedia("(min-resolution:144dpi)")&&e.matchMedia("(min-resolution:144dpi)").matches,oa=T("windows nt"),ra=-1!==ba.search(/windows nt [1-5]\./),sa=-1!==ba.search(/windows nt 5\.[12]/),ta=ra&&!sa;T("windows nt 10");
    var ua=T("windows phone"),va=T("macintosh"),wa=T("Mb2345Browser"),xa=T("ipad;")||T("ipad "),ya=xa&&la,za=T("ipod touch;"),Aa=T("iphone;")||T("iphone "),Ba=Aa||xa||za,Ca=Ba&&-1!==ba.search(/ os [456]_/);Ba&&ba.search(/ os [4-8]_/);var Ea=Ba&&-1!==ba.search(/ os [78]_/);Ba&&T("os 8_");var Fa=Ba&&T("os 10_"),Ga=T("android"),Ha=-1!==ba.search(/android [123]/),Ka=T("android 4");Ga&&-1===ba.search(/android [1-4]/)||ba.search(/android 4.4/);
    var La=Ga?"android":Ba?"ios":oa?"windows":va?"mac":"other",Ma=ka&&!e.XMLHttpRequest,Na=ka&&!da.querySelector,Oa=ka&&!da.addEventListener,Pa=ka&&T("ie 9"),Qa=ka&&T("msie 10"),Ra=ka&&T("rv:11"),Sa=T("edge"),Ta=T("qtweb"),Ua=T("ucbrowser"),Va=T("alipay")||Ga&&Ua,Wa=T("miuibrowser"),Xa=T("micromessenger"),Ya=T("mqqbrowser"),Za=T("baidubrowser"),chrome=(T("chrome")||T("crios"))&&!Xa&&!Za&&!Ya&&!Sa&&!Wa,ab=chrome&&T("chromium"),bb=chrome&&!ab&&30<parseInt(ba.split("chrome/")[1]),cb=T("firefox"),db=cb&&
        27<parseInt(ba.split("firefox/")[1]),eb=(va||Ba)&&T("safari")&&T("version/"),fb=va&&eb&&7<parseInt(ba.split("version/")[1]),gb=Ba&&T("aliapp"),hb=Ba&&(!Ya&&!Ua&&!Xa&&!chrome&&!cb&&!eb||gb),ib=Ga||Ba||ua||T("mobile"),jb=e.navigator&&e.navigator.msPointerEnabled&&!!e.navigator.msMaxTouchPoints,kb=e.navigator&&e.navigator.pointerEnabled&&!!e.navigator.maxTouchPoints,lb=kb||jb,mb="ontouchstart"in da||lb,nb=function(){if(!ib)return e.devicePixelRatio||1;var a=document.getElementsByTagName("meta");if(window.parent&&
        window.parent!==window)try{if(window.parent.location.origin===window.location.origin)a=window.parent.document.getElementsByTagName("meta");else return 1}catch(b){return 1}for(var c=a.length-1;0<=c;c-=1)if("viewport"===a[c].name){var c=a[c].content,d;-1!==c.indexOf("initial-scale")&&(d=parseFloat(c.split("initial-scale=")[1]));a=-1!==c.indexOf("minimum-scale")?parseFloat(c.split("minimum-scale=")[1]):0;c=-1!==c.indexOf("maximum-scale")?parseFloat(c.split("maximum-scale=")[1]):Infinity;if(d){if(c>=
        a)return d>c?c:d<a?a:d}else if(c>=a)return 1<=a?1:Math.min(c,1);console&&console.log&&console.log("viewport\u53c2\u6570\u4e0d\u5408\u6cd5");return null}}(),ob=la&&(!ib||!!nb&&1<=nb),pb=ka&&"transition"in fa.style,qb=!!da.createElementNS&&!!da.createElementNS("http://www.w3.org/2000/svg","svg").createSVGRect,rb=da.createElement("canvas"),sb=!(!rb||!rb.getContext),vb=window.URL||window.webkitURL,wb=!ka&&!(Ua&&Ga)&&window.Worker&&vb&&vb.createObjectURL&&window.Blob,xb="",ia="",yb=0,zb={alpha:!0,antialias:!0,
        depth:!1,failIfMajorPerformanceCaveat:!0,preserveDrawingBuffer:!0,stencil:!1},Ab=function(){if(!sb||!wb||hb)return!1;for(var a=["webgl","experimental-webgl","moz-webgl"],b=null,c=0;c<a.length;c+=1){try{b=rb.getContext(a[c],zb)}catch(d){}if(b){if(b.drawingBufferWidth!==rb.width||b.drawingBufferHeight!==rb.height)break;if(!b.getShaderPrecisionFormat||!b.getParameter||!b.getExtension)break;yb=b.getParameter(b.MAX_RENDERBUFFER_SIZE);var f=b.getParameter(b.MAX_VIEWPORT_DIMS);if(!f)break;yb=Math.min(yb,
        f[0],f[1]);eb&&"mac"==La&&(yb=Math.min(yb,4096));f=Math.max(screen.width,screen.height);ob&&(f*=Math.min(2,window.devicePixelRatio||1));if(f>yb)break;if(23>b.getShaderPrecisionFormat(35632,36338).precision||23>b.getShaderPrecisionFormat(35633,36338).precision)break;ia=b.getExtension("WEBGL_debug_renderer_info")?b.getParameter(37446):null;if((b=ha())&&-1!==ja.indexOf(b))break;xb=a[c];return!0}}return!1}(),Bb=Ab&&!ib&&(bb||db||fb)&&("mac"==La||"windows"==La),Cb=!sb||Ta||ua||ib&&cb||Pa||Ca||ya||za||
        Ha||T("gt-n710")||ta,Db=!Cb&&!Bb&&(Ka||Ea||Ba&&Xa||!ib),Eb=Bb?"vw":Cb?"d":Db?"dv":"v",Fb=T("webkit"),Gb="WebKitCSSMatrix"in e&&"m11"in new window.WebKitCSSMatrix,Hb="MozPerspective"in fa.style,Ib="OTransition"in fa.style,Jb=pb||Gb||Hb||Ib,Kb=void 0!==config[8]?config[8]:!0,Lb=void 0!==config[9]?config[9]:!0,Mb=void 0!==config[10]?config[10]:!0,Nb=void 0!==config[11]?config[11]:!0,Ob=void 0!==config[12]?config[12]:null,Pb=!qb&&ib&&sb,Qb=!0;
    try{if("undefined"===typeof e.localStorage)Qb=!1;else{var Rb=(new Date).getTime()+"";e.localStorage.setItem("_test",Rb);e.localStorage.getItem("_test")!==Rb&&(Qb=!1);e.localStorage.removeItem("_test")}}catch(Sb){Qb=!1}
    config.j={size:Aa?100:Ga?200:500,Du:va,b8:oa,HK:Ba,OZ:Fa,Eg:Ga,L4:Ha,GJ:Va,jr:La,lz:Za,Z6:Ya,IM:eb,o3:Xa,bo:ka,Kg:Ma,Sq:Na,f6:Pa,AZ:Qa,nd:Oa,CZ:ka&&!Ra,v_:wa,Cu:Qb,Uf:Qb&&Nb&&!ib&&chrome,Ph:Ob,geolocation:ib||ka&&!Oa||Sa,IC:Ua&&!chrome,chrome:chrome,Rz:la&&chrome,BJ:cb,U:ib,F6:ib&&Fb,A_:ib&&Gb,E6:ib&&e.opera,Rc:la,QC:nb,ha:ob,ud:mb,G_:jb,dM:kb,eM:lb,aX:57<=parseInt(ba.split("chrome/")[1]),m3:Fb,e6:pb,n3:Gb,y5:Hb,N6:Ib,gW:Jb,pj:qb,Xq:sb,UK:wb,Kv:Mb,MW:Ab,Yd:Bb,j3:xb,k3:zb,jK:ia,u_:yb,C3:!1,uY:Kb,Je:Kb&&
    !Cb,uW:Kb?Eb:"d",fo:Lb&&!!e.WebSocket&&!Za,L6:Pb,d0:sb||Pb?"c":"d"};var e=window,Tb={overlay:["style"],"AMap.IndoorMap":["AMap.CustomLayer","cvector"],"AMap.MarkerList":["AMap.TplUtils"]},Ub="http map anip layers overlay0 brender mrender".split(" ");config.Ed="main";config.j.ud&&(Ub+=",touch",config.Ed+="t");config.j.U||(Ub+=",mouse",config.Ed+="m");config.Ed+="c";config.j.Je&&(config.Ed+="v",Ub+=",vectorlayer,overlay",config.j.Yd?(config.Ed+="w",Ub+=",wgl"):(config.Ed+="cg",Ub+=",cmng,cgl"));
    if(config[7]){for(var Vb=[],Wb=config[7].split(","),Xb=0;Xb<Wb.length;Xb+=1){var Yb=Wb[Xb];Tb[Yb]&&Vb.push.apply(Vb,Tb[Yb]);Vb.push(Yb)}Ub+=","+Vb.join(",");config.Ed+=config[7].replace(",","").replace(eval("/AMap./gi"),"")}config.Nn=Tb;Ub+=",sync";config.wN=Ub.split(",");window.AMap=window.AMap||{};window.AMap.Pg="1.3.28.4";var Zb=window.AMap.PC={},mc=config[2].split(",")[0],nc=mc+"/theme/v"+config[4]+"/style1.3.28.4.css",oc=document.head||document.getElementsByTagName("head")[0];if(oc){var pc=document.createElement("link");pc.setAttribute("rel","stylesheet");pc.setAttribute("type","text/css");pc.setAttribute("href",nc);oc.insertBefore(pc,oc.firstChild)}else document.write("<link rel='stylesheet' href='"+nc+"'/>");
    function qc(a){var b=document,c=b.createElement("script");c.charset="utf-8";c.src=a;(a=b.body||oc)&&a.appendChild(c)}
    function rc(){for(var a=mc+"/maps/main?v="+config[4]+"&key="+config[0]+"&m="+config.wN.join(",")+"&vrs=1.3.28.4",b=document.getElementsByTagName("script"),c,d=0;d<b.length;d+=1)if(0===b[d].src.indexOf(mc.split(":")[1]+"/maps?")){c=b[d];break}config[5]||c&&c.async?qc(a):(document.write('<script id="amap_main_js" src=\''+a+"' type='text/javascript'>\x3c/script>"),setTimeout(function(){document.getElementById("amap_main_js")||qc(a)},1))}var sc=(new Date).getTime();
    Zb.__load__=function(a){a(config,sc);Zb.__load__=null};try{if(window.localStorage){var tc=window.localStorage["_AMap_"+config.Ed],uc=!1;tc?(tc=JSON.parse(tc),tc.version===window.AMap.Pg?(eval(tc.script),Zb.loaded=!0):uc=!0):uc=!0;if(uc)for(Xb in window.localStorage)window.localStorage.hasOwnProperty(Xb)&&0===Xb.indexOf("_AMap_")&&window.localStorage.removeItem(Xb)}}catch(vc){}Zb.loaded||(rc(),config.wN=void 0);
})(["",[113.751453,22.438581,114.628467,22.861748,114.085947,22.547],"http://webapi.amap.com",1,"1.3",null,"440300","",true,true,true,true,"1496841095-1"])

  function Gaodemap(inputNode,ltyArr,mapcont) {
    this.inputNode =inputNode;
    this.map = null;
    this.ltyArr = ltyArr;
    this.markers = [];
    this.lnglatXY = []; // 已知点坐标
    this.adcode = null; // 区域编号
    this.mapcont = mapcont;
    this.init();
  };

  // 地图初始化
  Gaodemap.prototype.init = function () {
    this.createMap();
    this.addTollbar();
    if(!!!this.ltyArr){
      this.getInitlocation();
    }else{
      this.lnglatXY = this.ltyArr;
      this.getCoordinate();
    }
    if(!!!this.mapcont){    // 不需要定位
      this.autoComplate();
    }

    if (typeof navigator.geolocation != "object") {   // 检测IE8浏览器
      this.showCityInfo();
    }
  };

  //创建高德地图对象
  Gaodemap.prototype.createMap = function () {
    var that = this,
    //初始化地图对象，加载地图]
      mapContentStr = this.mapcont ? 'mapcont' : 'mapContent';
    this.map = new AMap.Map(mapContentStr, {
      resizeEnable: true,
      zoom: 5
    });
    this.map.on('click', function (e) {
      that.map.remove(that.markers);                                            // 移除所有的定位图标
      that.lnglatXY = [e.lnglat.getLng(), e.lnglat.getLat()];               // 获取当前经纬度
      that.getCoordinate();
    });

  };

  //获取用户所在城市信息
  Gaodemap.prototype.showCityInfo = function () {
    //加载IP定位插件
    var that = this;
    this.map.plugin(["AMap.CitySearch"], function () {
      //实例化城市查询类
      var citysearch = new AMap.CitySearch();

        function Gaodemap(inputNode,ltyArr,mapcont) {
          this.inputNode = $(inputNode);
          this.map = null;
          this.ltyArr = ltyArr;
          this.markers = [];
          this.lnglatXY = []; // 已知点坐标
          this.adcode = null; // 区域编号
          this.mapcont = mapcont;
          this.init();
        };

        // 地图初始化
        Gaodemap.prototype.init = function () {
          this.createMap();
          this.addTollbar();
          if(!!!this.ltyArr){
            this.getInitlocation();
            this.inputNode.val('')
          }else{
            this.lnglatXY = this.ltyArr;
            this.getCoordinate();
          }
          if(!!!this.mapcont){    // 不需要定位
            this.autoComplate();
          }

          if (typeof navigator.geolocation != "object") {   // 检测IE8浏览器
            this.showCityInfo();
          }
        };

        //创建高德地图对象
        Gaodemap.prototype.createMap = function () {
          var that = this,
            //初始化地图对象，加载地图]
            mapContentStr = this.mapcont ? 'mapcont' : 'mapContent';
          this.map = new AMap.Map(mapContentStr, {
            resizeEnable: true,
            zoom: 5
          });
          this.map.on('click', function (e) {
            that.map.remove(that.markers);                                            // 移除所有的定位图标
            that.lnglatXY = [e.lnglat.getLng(), e.lnglat.getLat()];               // 获取当前经纬度
            that.getCoordinate();
          });

        };

        //获取用户所在城市信息
        Gaodemap.prototype.showCityInfo = function () {
          //加载IP定位插件
          var that = this;
          this.map.plugin(["AMap.CitySearch"], function () {
            //实例化城市查询类
            var citysearch = new AMap.CitySearch();
            //自动获取用户IP，返回当前城市
            citysearch.getLocalCity();
            AMap.event.addListener(citysearch, "complete", function (result) {
              if (result && result.city && result.bounds) {
                var cityinfo = result.city;
                var citybounds = result.bounds;
                that.inputNode.val(cityinfo);  // IE8初始化显示当前城市
                console.log(5555)
                //地图显示当前城市
                that.map.setBounds(citybounds);
              } else {
                console.log("您当前所在城市：" + result.info + "");
              }
            });
            AMap.event.addListener(citysearch, "error", function (result) {
              console.log(result.info);
            });
          });
        };

        // 加载工具条插件
        Gaodemap.prototype.addTollbar = function () {
          var that = this;
          this.map.plugin(["AMap.ToolBar"], function () {
            that.map.addControl(new AMap.ToolBar());
          });
          if (location.href.indexOf('&guide=1') !== -1) {
            this.map.setStatus({scrollWheel: false})
          }
        };

        //获取初始化位置
        Gaodemap.prototype.getInitlocation = function () {
          debugger;
          var that = this;
          this.map.plugin('AMap.Geolocation', function () {
            geolocation = new AMap.Geolocation({
              enableHighAccuracy: true,//是否使用高精度定位，默认:true
              timeout: 10000,          //超过10秒后停止定位，默认：无穷大
              buttonOffset: new AMap.Pixel(10, 20),//定位按钮与设置的停靠位置的偏移量，默认：Pixel(10, 20)
              zoomToAccuracy: true,      //定位成功后调整地图视野范围使定位位置及精度范围视野内可见，默认：false
              buttonPosition: 'RB'
            });
            that.map.addControl(geolocation);
            geolocation.getCurrentPosition();
            AMap.event.addListener(geolocation, 'complete', that.onComplete.bind(that));//返回定位信息,bind()方法，阻止this的隐式丢失
            AMap.event.addListener(geolocation, 'error', that.onError);      //返回定位出错信息
          })
        };

        // 地址提示输入
        Gaodemap.prototype.autoComplate = function () {
          var that = this;
          this.map.plugin('AMap.Autocomplete', function () {//回调函数
            var autoOptions = {         //实例化Autocomplete
              city: "",               //城市，默认全国
              input: "addressSearch"        //使用联想输入的input的id
            };
            var autocomplete = new AMap.Autocomplete(autoOptions);
            AMap.service(["AMap.PlaceSearch"], function () {
              var placeSearch = new AMap.PlaceSearch({
                map: that.map
              });
              //构造地点查询类
              AMap.event.addListener(autocomplete, "select", select);//注册监听，当选中某条记录时会触发
              function select(e) {
                console.log(e);
                that.lnglatXY = [e.poi.location.lng,e.poi.location.lat];
                placeSearch.setCity(e.poi.adcode);
                placeSearch.search(e.poi.name);  //关键字查询查询
                that.adcode = e.poi.adcode;
                $('.amap-layers').on('click', '.selected', function (e) {
                  that.map.remove(that.markers);          // 移除自定义选择图标
                  setTimeout(function () {                  // 异步处理等待dom生成再获取DOM节点
                    //var addressDetail = $('.amap-pl-pc .amap-lib-infowindow-content-wrap').children('div').text(); // 获取地址详情
                    var addressName = $('.amap-pl-pc .poi-name').text();                                           // 获取地址名
                    if (typeof navigator.geolocation == "object") {   // 检测IE8浏览器
                      that.inputNode.val(addressName);
                    }
                  }, 100);
                });
              };
            });
          });
        };
        // 你地理编码进行定位
        Gaodemap.prototype.regeocoder = function(){

        };

        //初始化定位成功调用函数
        Gaodemap.prototype.onComplete = function (data) {
          debugger;
          this.lnglatXY = [data.position.getLng(), data.position.getLat()];
          this.adcode = data.addressComponent.adcode;
          this.getCoordinate();
        };

        Gaodemap.prototype.onError = function (data) {

        };

        // 获取位置经纬度
        Gaodemap.prototype.getCoordinate = function () {
          var that = this;
          // console.log(this.lnglatXY);
          this.map.plugin(["AMap.Geocoder"], function () {
            var geocoder = new AMap.Geocoder({                              // 实例化逆向编码对象
              radius: 1000,
              extensions: "all"
            });
            geocoder.getAddress(that.lnglatXY, function (status, result) {        // 获取逆向编码状态
              if (status === 'complete' && result.info === 'OK') {
                console.log(result,88888)
                that.geocoder_CallBack(result);
              }
            });
          });
          // console.log(that.lnglatXY);
          marker = new AMap.Marker({                                           // 在当前经纬度添加定位图标
            'map': that.map,
            'position': that.lnglatXY
          });
          this.markers.push(marker);
          this.map.setFitView();
        };

        Gaodemap.prototype.geocoder_CallBack = function (data) {
          var that = this,
            address = data.regeocode.formattedAddress;         //返回地址描述
          // console.log(address);
          this.inputNode.val(address);
          console.log(22222222)

        };
        // $(function (window) {
        //实例化高德地图对象
        // var gaoMap = new Gaodemap($('#addressSearch'));
        // // window.gaodeMap = gaoMap;
        // console.log(gaoMap)
        return {gaoMap:Gaodemap}
        // });

      //自动获取用户IP，返回当前城市
      citysearch.getLocalCity();
      AMap.event.addListener(citysearch, "complete", function (result) {
        if (result && result.city && result.bounds) {
          var cityinfo = result.city;
          var citybounds = result.bounds;
          that.inputNode.val(cityinfo);  // IE8初始化显示当前城市
          console.log(5555)
          //地图显示当前城市
          that.map.setBounds(citybounds);
        } else {
          console.log("您当前所在城市：" + result.info + "");
        }
      });
      AMap.event.addListener(citysearch, "error", function (result) {
        console.log(result.info);
      });
    });
  };

  // 加载工具条插件
  Gaodemap.prototype.addTollbar = function () {
    var that = this;
    this.map.plugin(["AMap.ToolBar"], function () {
      that.map.addControl(new AMap.ToolBar());
    });
    if (location.href.indexOf('&guide=1') !== -1) {
      this.map.setStatus({scrollWheel: false})
    }
  };

  //获取初始化位置
  Gaodemap.prototype.getInitlocation = function () {
    var that = this;
    this.map.plugin('AMap.Geolocation', function () {
      geolocation = new AMap.Geolocation({
        enableHighAccuracy: true,//是否使用高精度定位，默认:true
        timeout: 10000,          //超过10秒后停止定位，默认：无穷大
        buttonOffset: new AMap.Pixel(10, 20),//定位按钮与设置的停靠位置的偏移量，默认：Pixel(10, 20)
        zoomToAccuracy: true,      //定位成功后调整地图视野范围使定位位置及精度范围视野内可见，默认：false
        buttonPosition: 'RB'
      });
      that.map.addControl(geolocation);
      geolocation.getCurrentPosition();
      AMap.event.addListener(geolocation, 'complete', that.onComplete.bind(that));//返回定位信息,bind()方法，阻止this的隐式丢失
      AMap.event.addListener(geolocation, 'error', that.onError);      //返回定位出错信息
    })
  };

  // 地址提示输入
  Gaodemap.prototype.autoComplate = function () {
    var that = this;
    this.map.plugin('AMap.Autocomplete', function () {//回调函数
      var autoOptions = {         //实例化Autocomplete
        city: "",               //城市，默认全国
        input: "addressSearch"        //使用联想输入的input的id
      };
      var autocomplete = new AMap.Autocomplete(autoOptions);
      AMap.service(["AMap.PlaceSearch"], function () {
        var placeSearch = new AMap.PlaceSearch({
          map: that.map
        });
        //构造地点查询类
        AMap.event.addListener(autocomplete, "select", select);//注册监听，当选中某条记录时会触发
        function select(e) {
          console.log(e);
          that.lnglatXY = [e.poi.location.lng,e.poi.location.lat];
          placeSearch.setCity(e.poi.adcode);
          placeSearch.search(e.poi.name);  //关键字查询查询
          that.adcode = e.poi.adcode;
          $('.amap-layers').on('click', '.selected', function (e) {
            that.map.remove(that.markers);          // 移除自定义选择图标
            setTimeout(function () {                  // 异步处理等待dom生成再获取DOM节点
              //var addressDetail = $('.amap-pl-pc .amap-lib-infowindow-content-wrap').children('div').text(); // 获取地址详情
              var addressName = $('.amap-pl-pc .poi-name').text();                                           // 获取地址名
              if (typeof navigator.geolocation == "object") {   // 检测IE8浏览器
                that.inputNode.val(addressName);
              }
            }, 100);
          });
        };
      });
    });
  };
  // 你地理编码进行定位
  Gaodemap.prototype.regeocoder = function(){

  };

  //初始化定位成功调用函数
  Gaodemap.prototype.onComplete = function (data) {
    this.lnglatXY = [data.position.getLng(), data.position.getLat()];
    this.adcode = data.addressComponent.adcode;
    this.getCoordinate();
  };

  Gaodemap.prototype.onError = function (data) {

  };

  // 获取位置经纬度
  Gaodemap.prototype.getCoordinate = function () {
    var that = this;
    // console.log(this.lnglatXY);
    this.map.plugin(["AMap.Geocoder"], function () {
      var geocoder = new AMap.Geocoder({                              // 实例化逆向编码对象
        radius: 1000,
        extensions: "all"
      });
      geocoder.getAddress(that.lnglatXY, function (status, result) {        // 获取逆向编码状态
        if (status === 'complete' && result.info === 'OK') {
          that.geocoder_CallBack(result);
        }
      });
    });
    marker = new AMap.Marker({                                           // 在当前经纬度添加定位图标
      'map': that.map,
      'position': that.lnglatXY
    });
    this.markers.push(marker);
    this.map.setFitView();
  };

  Gaodemap.prototype.geocoder_CallBack = function (data) {
    var that = this,
      address = data.regeocode.formattedAddress;         //返回地址描述
    this.inputNode.val(address);
    that.adcode=data.regeocode.addressComponent.adcode;
  };
    // return {gaoMap:Gaodemap}
